﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using X.Web;
using X.Entity;
using System.Security.Cryptography;
using System.Text;

namespace X.WebSite.Admin.User
{
    public partial class Detail : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { 
            
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            UserInfo userInfo = new UserInfo();
            string loginName = txtLoginName.Text.Trim().ToLower();
            string password = txtPassword.Text.Trim();

            if (Bll.User.Exists(loginName))
            {
                //TODO:Error
            }
            else
            {
                byte[] buffer = SHA1.Create().ComputeHash(Encoding.Unicode.GetBytes(password));
                userInfo.LoginName = loginName;
                userInfo.Password = buffer;
                userInfo.UserName = txtUserName.Text.Trim();

                Bll.User.Create(userInfo);
            }
        }
    }
}